package org.jeecg.modules.wms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.RestUtil;
import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.modules.oms.service.IProductSalesOrderService;
import org.jeecg.modules.wms.entity.WmsRequisition;
import org.jeecg.modules.wms.entity.WmsRequisitionAccessory;
import org.jeecg.modules.wms.entity.WmsRequisitionProfile;
import org.jeecg.modules.wms.entity.WmsRequisitionAttachment;
import org.jeecg.modules.wms.mapper.WmsRequisitionAccessoryMapper;
import org.jeecg.modules.wms.mapper.WmsRequisitionMapper;
import org.jeecg.modules.wms.mapper.WmsRequisitionProfileMapper;
import org.jeecg.modules.wms.service.IWmsRequisitionAccessoryService;
import org.jeecg.modules.wms.service.IWmsRequisitionAttachmentService;
import org.jeecg.modules.wms.service.IWmsRequisitionProfileService;
import org.jeecg.modules.wms.service.IWmsRequisitionService;
import org.jeecg.modules.wms.vo.WmsRequisitionExecuteVO;
import org.jeecg.modules.wms.vo.WmsRequisitionVO;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.HashMap;

/**
 * 领料单服务实现类
 */
@Service
@Slf4j
public class WmsRequisitionServiceImpl extends ServiceImpl<WmsRequisitionMapper, WmsRequisition> implements IWmsRequisitionService {

    @Autowired
    private WmsRequisitionMapper wmsRequisitionMapper;

    @Autowired
    private WmsRequisitionProfileMapper wmsRequisitionProfileMapper;

    @Autowired
    private WmsRequisitionAccessoryMapper wmsRequisitionAccessoryMapper;

    @Autowired
    private IWmsRequisitionAccessoryService wmsRequisitionAccessoryService;

    @Autowired
    private IWmsRequisitionAttachmentService wmsRequisitionAttachmentService;

    @Autowired
    private IWmsRequisitionProfileService wmsRequisitionProfileService;

    @Autowired
    private ISysBaseAPI sysBaseAPI;

    @Autowired
    private IProductSalesOrderService productSalesOrderService;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result<WmsRequisition> saveRequisition(WmsRequisitionVO wmsRequisitionVO) {
        try {
            List<WmsRequisitionProfile> profileList = wmsRequisitionVO.getProfileList();
            List<WmsRequisitionAccessory> accessoryList = wmsRequisitionVO.getAccessoryList();

            // 获取当前登录用户
            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
            Integer tenantId = Integer.valueOf(TenantContext.getTenant());
            String username = sysUser.getUsername();
            Date now = new Date();

            // 设置领料单基本信息
            wmsRequisitionVO.setTenantId(tenantId);
            wmsRequisitionVO.setCreateBy(username);
            wmsRequisitionVO.setCreateTime(now);
            wmsRequisitionVO.setUpdateBy(username);
            wmsRequisitionVO.setUpdateTime(now);
            wmsRequisitionVO.setStatus(0); // 默认待审核状态

            // 生成领料单号
            String requisitionNo = wmsRequisitionMapper.generateRequisitionNo(tenantId);
            wmsRequisitionVO.setRequisitionNo(requisitionNo);

            // 保存领料单
            boolean success = this.save(wmsRequisitionVO);
            if (!success) {
                return Result.error("保存领料单失败");
            }

            String requisitionId = wmsRequisitionVO.getId();

            // 保存型材明细
            if (profileList != null && !profileList.isEmpty()) {
                for (WmsRequisitionProfile profile : profileList) {
                    profile.setRequisitionId(requisitionId);
                    profile.setTenantId(tenantId);
                    profile.setCreateBy(username);
                    profile.setCreateTime(now);
                    profile.setUpdateBy(username);
                    profile.setUpdateTime(now);
                    profile.setStatus(0); // 默认未领料状态
                }
                // 批量保存型材明细
                for (WmsRequisitionProfile profile : profileList) {
                    wmsRequisitionProfileMapper.insert(profile);
                }
            }

            // 保存配件明细
            if (accessoryList != null && !accessoryList.isEmpty()) {
                for (WmsRequisitionAccessory accessory : accessoryList) {
                    accessory.setRequisitionId(requisitionId);
                    accessory.setTenantId(tenantId);
                    accessory.setCreateBy(username);
                    accessory.setCreateTime(now);
                    accessory.setUpdateBy(username);
                    accessory.setUpdateTime(now);
                    accessory.setStatus(0); // 默认未领料状态
                }
                // 批量保存配件明细
                for (WmsRequisitionAccessory accessory : accessoryList) {
                    wmsRequisitionAccessoryMapper.insert(accessory);
                }
            }

            return Result.OK("保存成功", wmsRequisitionVO);
        } catch (Exception e) {
            log.error("保存领料单失败", e);
            return Result.error("保存领料单失败: " + e.getMessage());
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result<WmsRequisition> updateRequisition(WmsRequisitionVO wmsRequisitionVO) {
        try {
            List<WmsRequisitionProfile> profileList = wmsRequisitionVO.getProfileList();
            List<WmsRequisitionAccessory> accessoryList = wmsRequisitionVO.getAccessoryList();

            // 检查领料单状态，只有待审核状态才能修改
            WmsRequisition oldRequisition = this.getById(wmsRequisitionVO.getId());
            if (oldRequisition == null) {
                return Result.error("领料单不存在");
            }
            if (oldRequisition.getStatus() != 0) {
                return Result.error("只有待审核状态的领料单才能修改");
            }

            // 获取当前登录用户
            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
            String username = sysUser.getUsername();
            Date now = new Date();

            // 更新领料单基本信息
            wmsRequisitionVO.setUpdateBy(username);
            wmsRequisitionVO.setUpdateTime(now);
            boolean success = this.updateById(wmsRequisitionVO);
            if (!success) {
                return Result.error("更新领料单失败");
            }

            String requisitionId = wmsRequisitionVO.getId();

            // 删除原有明细
            LambdaQueryWrapper<WmsRequisitionProfile> profileWrapper = new LambdaQueryWrapper<>();
            profileWrapper.eq(WmsRequisitionProfile::getRequisitionId, requisitionId);
            wmsRequisitionProfileMapper.delete(profileWrapper);

            LambdaQueryWrapper<WmsRequisitionAccessory> accessoryWrapper = new LambdaQueryWrapper<>();
            accessoryWrapper.eq(WmsRequisitionAccessory::getRequisitionId, requisitionId);
            wmsRequisitionAccessoryMapper.delete(accessoryWrapper);

            // 保存新的型材明细
            if (profileList != null && !profileList.isEmpty()) {
                for (WmsRequisitionProfile profile : profileList) {
                    profile.setRequisitionId(requisitionId);
                    profile.setCreateBy(username);
                    profile.setCreateTime(now);
                    profile.setUpdateBy(username);
                    profile.setUpdateTime(now);
                    profile.setStatus(0); // 默认未领料状态
                }
                // 批量保存型材明细
                for (WmsRequisitionProfile profile : profileList) {
                    wmsRequisitionProfileMapper.insert(profile);
                }
            }

            // 保存新的配件明细
            if (accessoryList != null && !accessoryList.isEmpty()) {
                for (WmsRequisitionAccessory accessory : accessoryList) {
                    accessory.setRequisitionId(requisitionId);
                    accessory.setCreateBy(username);
                    accessory.setCreateTime(now);
                    accessory.setUpdateBy(username);
                    accessory.setUpdateTime(now);
                    accessory.setStatus(0); // 默认未领料状态
                }
                // 批量保存配件明细
                for (WmsRequisitionAccessory accessory : accessoryList) {
                    wmsRequisitionAccessoryMapper.insert(accessory);
                }
            }

            return Result.OK("更新成功", wmsRequisitionVO);
        } catch (Exception e) {
            log.error("更新领料单失败", e);
            return Result.error("更新领料单失败: " + e.getMessage());
        }
    }

    @Override
    public WmsRequisitionVO getRequisitionById(String id) {
        // 获取领料单基本信息
        WmsRequisition wmsRequisition = this.getById(id);
        if (wmsRequisition == null) {
            return null;
        }

        // 获取型材明细列表
        List<WmsRequisitionProfile> profileList = wmsRequisitionProfileService.getProfileList(id);

        // 获取配件明细列表
        List<WmsRequisitionAccessory> accessoryList = wmsRequisitionAccessoryService.getAccessoryList(id);

        // 获取附件列表
        List<WmsRequisitionAttachment> attachmentList = wmsRequisitionAttachmentService.getAttachmentsByRequisitionId(id);

        // 组装VO对象
        WmsRequisitionVO vo = new WmsRequisitionVO();
        BeanUtils.copyProperties(wmsRequisition, vo);
        vo.setRequisition(wmsRequisition);
        vo.setProfileList(profileList);
        vo.setAccessoryList(accessoryList);
        vo.setAttachmentList(attachmentList);

        return vo;
    }

    @Override
    public List<WmsRequisitionProfile> getProfileList(String requisitionId) {
        return wmsRequisitionProfileMapper.selectByRequisitionId(requisitionId);
    }

    @Override
    public List<WmsRequisitionAccessory> getAccessoryList(String requisitionId) {
        return wmsRequisitionAccessoryMapper.selectByRequisitionId(requisitionId);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean removeRequisitionById(String id) {
        try {
            // 检查领料单状态，只有待审核状态才能删除
            WmsRequisition requisition = this.getById(id);
            if (requisition == null) {
                return false;
            }
            if (requisition.getStatus() != 0) {
                return false;
            }

            // 删除明细
            LambdaQueryWrapper<WmsRequisitionProfile> profileWrapper = new LambdaQueryWrapper<>();
            profileWrapper.eq(WmsRequisitionProfile::getRequisitionId, id);
            wmsRequisitionProfileMapper.delete(profileWrapper);

            LambdaQueryWrapper<WmsRequisitionAccessory> accessoryWrapper = new LambdaQueryWrapper<>();
            accessoryWrapper.eq(WmsRequisitionAccessory::getRequisitionId, id);
            wmsRequisitionAccessoryMapper.delete(accessoryWrapper);

            // 删除主表
            return this.removeById(id);
        } catch (Exception e) {
            log.error("删除领料单失败", e);
            return false;
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean removeRequisitionByIds(List<String> ids) {
        try {
            // 检查领料单状态，只有待审核状态才能删除
            LambdaQueryWrapper<WmsRequisition> wrapper = new LambdaQueryWrapper<>();
            wrapper.in(WmsRequisition::getId, ids);
            wrapper.ne(WmsRequisition::getStatus, 0);
            long count = this.count(wrapper);
            if (count > 0) {
                return false;
            }

            // 删除明细
            LambdaQueryWrapper<WmsRequisitionProfile> profileWrapper = new LambdaQueryWrapper<>();
            profileWrapper.in(WmsRequisitionProfile::getRequisitionId, ids);
            wmsRequisitionProfileMapper.delete(profileWrapper);

            LambdaQueryWrapper<WmsRequisitionAccessory> accessoryWrapper = new LambdaQueryWrapper<>();
            accessoryWrapper.in(WmsRequisitionAccessory::getRequisitionId, ids);
            wmsRequisitionAccessoryMapper.delete(accessoryWrapper);

            // 删除主表
            return this.removeByIds(ids);
        } catch (Exception e) {
            log.error("批量删除领料单失败", e);
            return false;
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result<?> submitRequisition(String id) {
        try {
            // 检查领料单状态
            WmsRequisition requisition = this.getById(id);
            if (requisition == null) {
                return Result.error("领料单不存在");
            }
            if (requisition.getStatus() != 0) {
                return Result.error("只有待审核状态的领料单才能提交审核");
            }

            // 获取当前登录用户
            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
            String username = sysUser.getUsername();
            Date now = new Date();

            // 更新领料单状态为待审核
            WmsRequisition updateRequisition = new WmsRequisition();
            updateRequisition.setId(id);
            updateRequisition.setStatus(0); // 确保状态为待审核
            updateRequisition.setUpdateBy(username);
            updateRequisition.setUpdateTime(now);
            boolean success = this.updateById(updateRequisition);

            if (success) {
                return Result.OK("提交审核成功");
            } else {
                return Result.error("提交审核失败");
            }
        } catch (Exception e) {
            log.error("提交领料单审核失败", e);
            return Result.error("提交审核失败: " + e.getMessage());
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result<?> approveRequisition(String id, String approver, String approveComment, List<Map<String, String>> attachments) {
        try {
            // 检查领料单状态
            WmsRequisition requisition = this.getById(id);
            if (requisition == null) {
                return Result.error("领料单不存在");
            }
            if (requisition.getStatus() != 0) {
                return Result.error("只有待审核状态的领料单才能审核");
            }

            // 获取当前登录用户
            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
            String username = sysUser.getUsername();
            Date now = new Date();

            // 更新领料单状态为已审核
            WmsRequisition updateRequisition = new WmsRequisition();
            updateRequisition.setId(id);
            updateRequisition.setStatus(1); // 已审核
            updateRequisition.setApprover(approver);
            updateRequisition.setApproveTime(now);
            updateRequisition.setApproveComment(approveComment);
            updateRequisition.setUpdateBy(username);
            updateRequisition.setUpdateTime(now);

            // 更新订单状态为待领料(6)和进度信息
            if (StringUtils.isNotBlank(requisition.getOrderId())) {
                try {
                    // 更新订单状态为待领料(6)
                    productSalesOrderService.updateOrderStatus(
                            requisition.getOrderId(),
                            5,
                            6,
                            sysUser.getId(),
                            "领料单号：" + requisition.getRequisitionNo() + "，审核通过");

                    log.info("订单状态更新成功：orderId={}, status=6(待领料)", requisition.getOrderId());
                } catch (Exception e) {
                    log.error("更新订单状态失败", e);
                    // 不影响主流程，继续执行
                }
            }

            boolean success = this.updateById(updateRequisition);

            // 保存附件信息
            if (success && attachments != null && !attachments.isEmpty()) {
                for (Map<String, String> attachment : attachments) {
                    // 从附件信息中提取数据
                    String fileName = attachment.get("fileName");
                    String filePath = attachment.get("filePath");
                    String fileType = attachment.get("fileType");

                    if (StringUtils.isNotBlank(fileName) && StringUtils.isNotBlank(filePath)) {
                        // 创建附件对象
                        WmsRequisitionAttachment attachmentEntity = new WmsRequisitionAttachment();
                        attachmentEntity.setRequisitionId(id);
                        attachmentEntity.setFileName(fileName);
                        attachmentEntity.setFilePath(filePath);
                        attachmentEntity.setFileType(fileType);
                        attachmentEntity.setUploadTime(now);
                        attachmentEntity.setUploader(username);
                        attachmentEntity.setCreateBy(username);
                        attachmentEntity.setCreateTime(now);
                        attachmentEntity.setTenantId(Integer.valueOf(TenantContext.getTenant()));

                        // 保存附件记录
                        wmsRequisitionAttachmentService.save(attachmentEntity);
                    }
                }
            }

            //成功后自动生成领料单



            if (success) {
                return Result.OK("审核通过成功");
            } else {
                return Result.error("审核通过失败");
            }
        } catch (Exception e) {
            log.error("审核领料单失败", e);
            return Result.error("审核通过失败: " + e.getMessage());
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result<?> rejectRequisition(String id, String approver, String approveComment) {
        try {
            // 检查领料单状态
            WmsRequisition requisition = this.getById(id);
            if (requisition == null) {
                return Result.error("领料单不存在");
            }
            if (requisition.getStatus() != 0) {
                return Result.error("只有待审核状态的领料单才能驳回");
            }

            // 获取当前登录用户
            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
            String username = sysUser.getUsername();
            Date now = new Date();

            // 更新领料单状态为已驳回
            WmsRequisition updateRequisition = new WmsRequisition();
            updateRequisition.setId(id);
            updateRequisition.setStatus(2); // 已驳回
            updateRequisition.setApprover(approver);
            updateRequisition.setApproveTime(now);
            updateRequisition.setApproveComment(approveComment);
            updateRequisition.setUpdateBy(username);
            updateRequisition.setUpdateTime(now);

            // 更新订单状态为已驳回(9)和进度信息
            if (StringUtils.isNotBlank(requisition.getOrderId())) {
                try {
                    // 更新订单状态为已驳回(9)
                    productSalesOrderService.updateOrderStatus(
                            requisition.getOrderId(),
                            5,
                            9,
                            sysUser.getId(),
                            "领料单号：" + requisition.getRequisitionNo() + "，驳回原因：" + approveComment);

                    log.info("订单状态更新成功：orderId={}, status=9(已驳回)", requisition.getOrderId());
                } catch (Exception e) {
                    log.error("更新订单状态失败", e);
                    // 不影响主流程，继续执行
                }
            }

            boolean success = this.updateById(updateRequisition);

            if (success) {
                return Result.OK("驳回成功");
            } else {
                return Result.error("驳回失败");
            }
        } catch (Exception e) {
            log.error("驳回领料单失败", e);
            return Result.error("驳回失败: " + e.getMessage());
        }
    }

    /**
     * 保存订单进度信息
     *
     * @param orderId         订单ID
     * @param progressTitle   进度标题
     * @param progressContent 进度内容
     * @param operator        操作人
     */
    private void saveOrderProgress(String orderId, String progressTitle, String progressContent, String operator) {
        if (StringUtils.isBlank(orderId)) {
            return;
        }

        try {
            // 构造请求参数
            Map<String, Object> params = new HashMap<>();
            params.put("orderId", orderId);
            params.put("progressTitle", progressTitle);
            params.put("progressContent", progressContent);
            params.put("operator", operator);
            params.put("progressTime", new Date());

            // 调用订单进度服务保存进度信息
            // 这里使用RestUtil进行HTTP调用，根据实际接口调整URL和参数
            String url = "http://localhost:8080/jeecg-boot/oms/orderProgress/save";
            // RestUtil.post(url, params);

            // 记录日志但不实际调用，避免接口不存在导致错误
            log.info("订单进度保存请求：url={}, params={}", url, params);
        } catch (Exception e) {
            log.error("保存订单进度信息异常", e);
            // 异常不向上抛出，避免影响主流程
        }
    }

    /**
     * 发送系统消息
     *
     * @param title   消息标题
     * @param content 消息内容
     * @param toUser  接收人
     */
    private void sendSystemMessage(String title, String content, String toUser) {
        try {
            MessageDTO messageDTO = new MessageDTO();
            messageDTO.setTitle(title);
            messageDTO.setContent(content);
            messageDTO.setToUser(toUser);
            messageDTO.setCategory("3"); // 系统消息
            sysBaseAPI.sendSysAnnouncement(messageDTO);
            log.info("系统消息发送成功：title={}, toUser={}", title, toUser);
        } catch (Exception e) {
            log.error("系统消息发送失败", e);
        }
    }

    /**
     * 获取订单状态描述
     *
     * @param status 状态值
     * @return 状态描述
     */
    private String getStatusDesc(Integer status) {
        switch (status) {
            case 0:
                return "草稿";
            case 1:
                return "待确认";
            case 2:
                return "已确认";
            case 3:
                return "生产中";
            case 4:
                return "已完成";
            case 5:
                return "已取消";
            case 6:
                return "待领料";
            case 7:
                return "已领料";
            case 8:
                return "待验收";
            case 9:
                return "已驳回";
            default:
                return "未知状态";
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result<?> executeRequisition(WmsRequisitionExecuteVO executeVO) {
        try {
            String requisitionId = executeVO.getRequisitionId();
            List<WmsRequisitionExecuteVO.ProfileExecuteItem> profiles = executeVO.getProfiles();
            List<WmsRequisitionExecuteVO.AccessoryExecuteItem> accessories = executeVO.getAccessories();

            // 检查领料单状态
            WmsRequisition requisition = this.getById(requisitionId);
            if (requisition == null) {
                return Result.error("领料单不存在");
            }
            if (requisition.getStatus() != 1) {
                return Result.error("只有已审核状态的领料单才能执行领料");
            }

            // 获取当前登录用户
            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
            String username = sysUser.getUsername();
            Date now = new Date();

            // 处理型材明细
            if (profiles != null && !profiles.isEmpty()) {
                for (WmsRequisitionExecuteVO.ProfileExecuteItem item : profiles) {
                    // 查询明细
                    WmsRequisitionProfile profile = wmsRequisitionProfileMapper.selectById(item.getId());
                    if (profile == null) {
                        continue;
                    }

                    // 更新领料状态和实际领料数量
                    WmsRequisitionProfile updateProfile = new WmsRequisitionProfile();
                    updateProfile.setId(item.getId());
                    updateProfile.setUpdateBy(username);
                    updateProfile.setUpdateTime(now);

                    // 判断领料状态
                    Integer actualQuantity = item.getActualQuantity();
                    if (actualQuantity >= profile.getQuantity()) {
                        updateProfile.setStatus(1); // 已领料
                    } else if (actualQuantity > 0) {
                        updateProfile.setStatus(2); // 部分领料
                    } else {
                        updateProfile.setStatus(0); // 未领料
                    }

                    wmsRequisitionProfileMapper.updateById(updateProfile);
                }
            }

            // 处理配件明细
            if (accessories != null && !accessories.isEmpty()) {
                for (WmsRequisitionExecuteVO.AccessoryExecuteItem item : accessories) {
                    // 查询明细
                    WmsRequisitionAccessory accessory = wmsRequisitionAccessoryMapper.selectById(item.getId());
                    if (accessory == null) {
                        continue;
                    }

                    // 更新领料状态和实际领料数量
                    WmsRequisitionAccessory updateAccessory = new WmsRequisitionAccessory();
                    updateAccessory.setId(item.getId());
                    updateAccessory.setUpdateBy(username);
                    updateAccessory.setUpdateTime(now);

                    // 判断领料状态
                    Integer actualQuantity = item.getActualQuantity();
                    if (actualQuantity >= accessory.getQuantity()) {
                        updateAccessory.setStatus(1); // 已领料
                    } else if (actualQuantity > 0) {
                        updateAccessory.setStatus(2); // 部分领料
                    } else {
                        updateAccessory.setStatus(0); // 未领料
                    }

                    wmsRequisitionAccessoryMapper.updateById(updateAccessory);
                }
            }

            return Result.OK("执行领料成功");
        } catch (Exception e) {
            log.error("执行领料失败", e);
            return Result.error("执行领料失败: " + e.getMessage());
        }
    }

    @Override
    public Result<?> importExcel(MultipartFile file, HttpServletRequest request) {
        // 暂不实现Excel导入功能
        return Result.error("暂不支持Excel导入功能");
    }

    @Override
    public IPage<WmsRequisition> queryPageList(Page<WmsRequisition> page, Map<String, Object> params) {
        return wmsRequisitionMapper.queryPageList(page, params);
    }

    @Override
    public List<WmsRequisition> queryExportList(Map<String, Object> params) {
        return wmsRequisitionMapper.queryExportList(params);
    }
} 